﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogisticsAdmin.Common;
using System.Data.SqlClient;

namespace LogisticsAdmin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #region 用户操作


        /// <summary>
        /// 登录事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //1、获取用户填写信息
            //2、判断空值
            //3、用户账号和密码VS     ---ADO.NET---          数据库验证信息SQLSERVER
            string account = txtAccount.Text;
            string pwd = txtPwd.Text;
            if (string.IsNullOrWhiteSpace(account))
            {
                JSHelper.Alert(this, "账号不能为空");
                return;
            }
            if (string.IsNullOrWhiteSpace(pwd))
            {
                JSHelper.Alert(this, "密码不能为空");
                return;
            }
            string sql = "SELECT username FROM [User] WHERE Account=@acc  AND Password=@pwd";
            SqlParameter[] para = {
            new SqlParameter("@acc",account),
            new SqlParameter("@pwd",pwd)
            };
            object result = SQLHelper.ExecuteScalar(sql,para);
            if (result != null)
            {
                JSHelper.Alert(this, "登录成功");
            }
            else
            {
                JSHelper.Alert(this, "登录失败");
            }
        }



        #endregion
    }
}